<?php 

namespace app\controller\api;

use app\exception\ErrnoPlus;
use app\service\AppMchTableService;
use Exception;
use share\controller\ApiBaseController;
use share\exception\ApiException;

use share\utils\Helper;

class AppMchTableController extends ApiBaseController{

    public function initValidate(){
    }

    /**
     * 支付商户信息
     */
    public function list_action(){
        $vendor = request()->param("vendor");
        if(!$vendor){
            throw new ApiException("vendor is error",ErrnoPlus::PARAM_ERROR);
        }        
        $res = AppMchTableService::getAllByAVendor($vendor);
        if (!$res) {
            self::fail("app and mch info not set or set error",ErrnoPlus::COMMON_ERROR);
            //throw new ApiException("app and mch info set error",ErrnoPlus::COMMON_ERROR);
        }
        $data = Helper::listArrayColumn($res,['app_id' => 'appId','mch_id' => 'mchId','app_secret' => 'appSecret','pay_type' => 'payType']);
        return self::ok($data);
    }

}